<?php 
	session_start();
	$var1= $_SESSION["registrado"];
	$var2= $_SESSION["administrador"];
	if ($var1 == null): {
		echo ("User not registered");
	} elseif ($var2 == 0): { 
			echo ("User without permissions");
	} else : {
?>


<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-responsive.css" rel="stylesheet"	media="screen">

<title>My project manager</title>

<style type="text/css">@import url("css/calendar-blue.css");</style>
<script src="js/calendar.js" type="text/javascript"></script>
<script src="js/calendar-es.js" type="text/javascript"></script>
<script src="js/calendar-setup.js" type="text/javascript"></script>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>


<script type="text/javascript">
    (function($) {
        $(document).ready(function(){
            $("#datepicker").datepicker({ 
                dateFormat: "yy-mm-dd" 
            });
            $("#datepicker2").datepicker({ 
                dateFormat: "yy-mm-dd" 
            });
      });
    })(jQuery);
</script>

<style type="text/css">
  body {
    padding-top: 60px;
    padding-bottom: 40px;
  }
  .sidebar-nav {
    padding: 9px 0;
  
  }
    .container {
    padding-top: 100px;
  }

    .finish {
    padding-top: 150px;
    padding-left: 25px;
    padding-right: 25px;
  }
  

  
  @media (max-width: 980px) {
    /* Enable use of floated navbar text */
    .navbar-text.pull-right {
      float: none;
      padding-left: 5px;
      padding-right: 5px;
    }
  }
</style>

</head>

<body>
<?php include ('configuration.php'); ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap.js"></script>


<div class="navbar navbar-inverse navbar-fixed-top">
	<div class="navbar-inner">
		<div class="container-fluid">
			<button type="button" class="btn btn-navbar" data-toggle="collapse"
				data-target=".nav-collapse">
				<span class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="brand"href="http://localhost/bases--grupo10/homeAdmin.php?">My project manager</a>
			<div class="nav-collapse collapse">
				<p class="navbar-text pull-right">
				
					<a href="http://localhost/bases--grupo10/logout.php?" class="navbar-link">Log out</a>
				</p>
				<ul class="nav">
					<li class="active"><a href="http://localhost/bases--grupo10/homeAdmin.php?">Home</a></li>
					<li><a href="http://localhost/bases--grupo10/about.php?">About</a></li>
					<li><a href="http://localhost/bases--grupo10/contact.php?">Contact</a></li>
				</ul>
			</div>
		</div>
	</div>
</div>
	
<div class="span12" >	
    <h1 class="muted">Modify project > </h1><h1 style="position:absolute;top:50px;left:360px;font-weight:bold"><font size="5"><u> Make changes</u></font></h1>					
</div>
	
	<?php
	//hago consulta con el id q me he traido del post de modifyProject y con eso me traigo todos los datos y relleno
    $id_proj = $_SESSION["id_proj"];
    $name_proj = $_SESSION["name_proj"];  
	$deleted = $_SESSION["deleted"];
	$adv = $_SESSION["adv"];
	$initial = $_SESSION["initial"];
	$final = $_SESSION["final"];   
  	$version = $_SESSION["version"];
  	
  	//lo que me he traido de la pantalla anterior ya es la ultima version del proyecto seleccionado
    $q1 =  mysql_query ("SELECT p.id_project, p.name_project, p.deleted, p.id_version, p.advantage, p.initial_date, p.final_date FROM project p WHERE p.id_project='$id_proj' AND p.id_version=(select max(P2.id_version) from project P2 where p.id_project=P2.id_project)"); 
    $q1_array = mysql_fetch_assoc($q1);
    $name=$q1_array['name_project']; 
    $_SESSION['name_proj'] = $name;   
    $deleted=$q1_array['deleted'];
    $_SESSION['deleted'] = $deleted;   
    $advantage=$q1_array['advantage'];
    $_SESSION['adv'] = $advantage;   
    $initial_date=$q1_array['initial_date'];
    $_SESSION['initial'] = $initial_date;   
    $final_date=$q1_array['final_date'];
    $_SESSION['final'] = $final_date;   
    $id_version=$q1_array['id_version'];
    $_SESSION['version'] = $id_version;  
   
	?>
	
<form class="form-horizontal" method="post" action="modifyProject4.php">
    <div class="container">
    	<div class="span12">
    	<div class="container-fluid">	 
        	<div class="span5">
        	    <div class="container-fluid">	
        	       <div class="control-group">
                        <label class="control-label">Name project: </label>
                    	<div class="controls">
                          	<input type="text" id="name_project" name="name_project" value="<?php echo $name;?>">
                       	</div>
                    </div>
            		
        			<div class="control-group">
            			<label class="control-label">Initial date: </label>
            			<div class="controls">
            				<input id="datepicker" name="fecha" type="text" value="<?php echo $initial_date;?>">
    			        </div>
    	            </div>
    		
    	            <div class="control-group">
            			<label class="control-label">Final date: </label>
            			<div class="controls">
            				<input id="datepicker2" name="fecha2" type="text" value="<?php echo $final_date;?>">
    			        </div>
    	            </div>
                
                    <div class="control-group">
        	            <label class="control-label">Advance: </label>
                    	<div class="controls">
                          	<input type="text" id="advantage" name="advantage" value="<?php echo $advantage;?>">
                       	</div>
                     </div>  
                         
                     <div class="control-group">
    	            	 <div class="controls">
                       		 <input type="hidden" id="id_ver" name="id_ver" value="<?php echo $id_version;?>">
                    	 </div>
                	 </div>
                     
                      <div class="control-group">
    	            	 <div class="controls">
                       		 <input type="hidden" id="deleted" name="deleted" value="<?php echo $deleted;?>">
                    	 </div>
                	 </div>
                	 
                	 <div class="control-group">
    	            	 <div class="controls">
                       		 <input type="hidden" id="id_pro" name="id_pro" value="<?php echo $id_proj;?>">
                     	</div>
                 	</div>          
                    </div>  
        	    </div>
            
                <div class="span1">
                </div>
                
                <div class="span5">
            	   <div class="container-fluid">	
            	
            	       <div class="control-group">
                    	    <a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/modifyProject3.php?" >Modify members and responsibles</a>
                       </div>
                       
                       <div class="control-group">
                           <a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/showMembers.php?id_pro=<?php echo $id_proj;?>" >Show members</a>
                       </div>
                      
                       <div class="control-group">
                            <input class="btn btn-primary" type="submit" value="Modify">  
                       </div>
                   </div>
            </div>
        </div>
        </div>
    </div>
    
    <div class="finish"> 
        <a class="btn btn-primary pull-right" type="button" href="http://localhost/bases--grupo10/homeAdmin.php?" >Finish</a>
	    <a class="btn btn-primary pull-left" type="button" href="http://localhost/bases--grupo10/modifyProject.php?" >Back</a>
    </div>    
</form>

	
	
</body>
</html>

<?php }endif;?>